Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

elastic-agent install: Only uninstall when Agent is installed #3415

Merged
merged 6 commits into from
Sep 25, 2023

Conversation

ycombinator
Copy link
Contributor

@ycombinator ycombinator commented Sep 14, 2023

What does this PR do?

This PR improves the elastic-agent install experience by only trying to uninstall the existing Elastic Agent installation if Elastic Agent is currently installed.

Why is it important?

So the progress messages shown to the user during elastic-agent install are not misleading by suggesting that the existing Elastic Agent installation is being uninstalled, even when there is no Elastic Agent currently installed.

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have made corresponding change to the default configuration files
  • I have added tests that prove my fix is effective or that my feature works
  • I have added an entry in ./changelog/fragments using the changelog tool
  • I have added an integration test or an E2E test

How to test this PR locally

  1. Start with a host where Elastic Agent is NOT currently installed.
  2. Build Elastic Agent from this PR and install it.
     sudo ./elastic-agent install
    
  3. Verify that the progress messages shown do NOT include a message about Elastic Agent being uninstalled.
  4. Verify that the installation succeeds.
     sudo elastic-agent status
    
  5. Try to install Elastic Agent again.
     sudo ./elastic-agent install
    
  6. Verify that installation fails with a message about Elastic Agent already being installed.
  7. Try to install Elastic Agent again, this time with the --force flag.
     sudo ./elastic-agent install --force
    
  8. Verify that the progress messages shown include a message about Elastic Agent being uninstalled.
  9. Verify that the installation succeeds.
     sudo elastic-agent status
    

Related issues

@@ -83,7 +83,7 @@ func installCmd(streams *cli.IOStreams, cmd *cobra.Command) error {

nonInteractive, _ := cmd.Flags().GetBool("non-interactive")
if nonInteractive {
fmt.Fprintf(streams.Out, "Installing in non-interactive mode.")
fmt.Fprintln(streams.Out, "Installing in non-interactive mode.")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not strictly related to the changes in this PR.

@elasticmachine
Copy link
Contributor

elasticmachine commented Sep 14, 2023

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview preview

Expand to view the summary

Build stats

  • Start Time: 2023-09-25T15:17:59.007+0000

  • Duration: 25 min 48 sec

Test stats 🧪

Test Results
Failed 0
Passed 6313
Skipped 59
Total 6372

💚 Flaky test report

Tests succeeded.

🤖 GitHub comments

Expand to view the GitHub comments

To re-run your PR in the CI, just comment with:

  • /test : Re-trigger the build.

  • /package : Generate the packages.

  • run integration tests : Run the Elastic Agent Integration tests.

  • run end-to-end tests : Generate the packages and run the E2E Tests.

  • run elasticsearch-ci/docs : Re-trigger the docs validation. (use unformatted text in the comment!)

@ycombinator ycombinator added >bug Team:Elastic-Agent Label for the Agent team labels Sep 14, 2023
@ycombinator ycombinator marked this pull request as ready for review September 14, 2023 11:51
@ycombinator ycombinator requested a review from a team as a code owner September 14, 2023 11:51
@elasticmachine
Copy link
Contributor

Pinging @elastic/elastic-agent (Team:Elastic-Agent)

@elasticmachine
Copy link
Contributor

elasticmachine commented Sep 14, 2023

🌐 Coverage report

Name Metrics % (covered/total) Diff
Packages 98.78% (81/82) 👍
Files 66.102% (195/295) 👍
Classes 65.693% (360/548) 👍
Methods 52.769% (1134/2149) 👍
Lines 38.18% (12853/33664) 👎 -0.047
Conditionals 100.0% (0/0) 💚

@ycombinator ycombinator force-pushed the install-uninstall-with-force branch from 4f5f10f to f8a8bf1 Compare September 14, 2023 14:28
Copy link
Contributor

@blakerouse blakerouse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@ycombinator ycombinator force-pushed the install-uninstall-with-force branch from f8a8bf1 to df1d988 Compare September 19, 2023 17:03
@ycombinator
Copy link
Contributor Author

/test

@mergify
Copy link
Contributor

mergify bot commented Sep 21, 2023

This pull request is now in conflicts. Could you fix it? 🙏
To fixup this pull request, you can check out it locally. See documentation: https://help.github.com/articles/checking-out-pull-requests-locally/

git fetch upstream
git checkout -b install-uninstall-with-force upstream/install-uninstall-with-force
git merge upstream/main
git push upstream install-uninstall-with-force

Copy link
Member

@pchila pchila left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ycombinator could you please solve the conflicts so we can merge this ?

@ycombinator ycombinator force-pushed the install-uninstall-with-force branch from df1d988 to 090831e Compare September 25, 2023 14:29
@elastic-sonarqube
Copy link

@ycombinator ycombinator enabled auto-merge (squash) September 25, 2023 18:05
@ycombinator ycombinator added backport-v8.10.0 Automated backport with mergify and removed backport-skip labels Sep 25, 2023
@ycombinator ycombinator merged commit 0c43005 into elastic:main Sep 25, 2023
mergify bot pushed a commit that referenced this pull request Sep 25, 2023
* Only uninstall if --force is present

* Improve help text

* Add missing newline

* Don't pass force

* Fix more conflicts

* Fixing compile error introduced while resolving conflicts

(cherry picked from commit 0c43005)

# Conflicts:
#	internal/pkg/agent/install/install.go
ycombinator added a commit that referenced this pull request Sep 29, 2023
* Only uninstall if --force is present

* Improve help text

* Add missing newline

* Don't pass force

* Fix more conflicts

* Fixing compile error introduced while resolving conflicts

(cherry picked from commit 0c43005)

# Conflicts:
#	internal/pkg/agent/install/install.go
ycombinator added a commit that referenced this pull request Oct 12, 2023
* Only uninstall if --force is present

* Improve help text

* Add missing newline

* Don't pass force

* Fix more conflicts

* Fixing compile error introduced while resolving conflicts

(cherry picked from commit 0c43005)

# Conflicts:
#	internal/pkg/agent/install/install.go
ycombinator added a commit that referenced this pull request Oct 12, 2023
…gent is installed (#3472)

* `elastic-agent install`: Only uninstall when Agent is installed (#3415)

* Only uninstall if --force is present

* Improve help text

* Add missing newline

* Don't pass force

* Fix more conflicts

* Fixing compile error introduced while resolving conflicts

(cherry picked from commit 0c43005)

# Conflicts:
#	internal/pkg/agent/install/install.go

* Addressing conflicts

---------

Co-authored-by: Shaunak Kashyap <[email protected]>
@ycombinator ycombinator deleted the install-uninstall-with-force branch November 27, 2023 20:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-v8.10.0 Automated backport with mergify >bug skip-changelog Team:Elastic-Agent Label for the Agent team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Misguiding information- Uninstalling current Elastic Agent is shown under CLI while installing elastic-agent.
4 participants